<template>
 <el-container>

  <el-header>
    <div class="title-header" @click="myReimbursement()">
      Ukraine Finance System
    </div>
    <div class="user">
      <el-dropdown class="user">
          <span class="el-dropdown-link">
            welcome:<span >{{name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
          </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item @click.native="logOut()">login out</el-dropdown-item>
          <el-dropdown-item @click.native="personInfo()">personal information</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>

  </el-header>

  <el-container>
    <el-aside :width="isCollapse ? '64px' : '260px'">
      <div class="toggle-button" @click="togleCollapse">|||</div>
      <el-menu
      @select="handleSelect"
      class="el-menu-vertical-demo"
      background-color="#373f41"
      text-color="#fff"
      active-text-color="#409FFF"
      unique-opened
      :collapse="isCollapse"
      :collapse-transition="false">
        <el-menu-item index="My Expense Account" @click="myReimbursement" >
          <i class="el-icon-menu"></i>
          <span slot="title">Reimbursement List</span>
        </el-menu-item>
        <el-menu-item index="Payroll Record" @click="payrollRecord" >
          <i class="el-icon-menu"></i>
          <span slot="title">Payroll Record</span>
        </el-menu-item>
        <el-menu-item @click="juseAdmin" index="Permissions Manage" v-if="level == 7 || level == 9">
          <i class="el-icon-menu"></i>
          <span slot="title">Permissions Management</span>
        </el-menu-item>
        <el-menu-item @click="goStaff" index="Staff Manage" v-if="level == 3 || level == 4 || level == 7 || level == 9">
            <i class="el-icon-menu"></i>
            <span>Staff Management</span>
        </el-menu-item>
        <el-menu-item index="Project Manage" @click="projectAdmin" v-if="level == 6 || level == 7 || level == 9">
          <i class="el-icon-menu"></i>
          <span slot="title">Project Management</span>
        </el-menu-item>
        <el-menu-item index="PE Salary Manage" @click="payAdmin" v-if=" level == 2 || level == 3 || level == 4 || level == 7 || level == 9">
          <i class="el-icon-menu"></i>
          <span slot="title">PE Salary Management</span>
        </el-menu-item>
        <el-menu-item index="测试用新增工资单" @click="payAdminTest" v-if="level == 9">
          <i class="el-icon-menu"></i>
          <span slot="title">测试用新增工资单</span>
        </el-menu-item>
        <el-menu-item index="支付凭证管理" @click="payment" v-if="level == 1 || level == 2 || level == 7 || level == 9">
          <i class="el-icon-menu"></i>
          <span>Certification Management</span>
        </el-menu-item>
        <el-menu-item index="测试用新增支付凭证" @click="paymentTest" v-if="level == 9">
          <i class="el-icon-menu"></i>
          <span slot="title">测试用新增支付凭证</span>
        </el-menu-item>
        <el-menu-item index="Expense Account Manage" @click="reimbursementManage" v-if="level == 2 || level == 5 || level == 6 || level == 7 || level == 9">
          <i class="el-icon-menu"></i>
          <span>Reimbursement Management</span>
        </el-menu-item>
    </el-menu>
    </el-aside>
    <el-container>
      <el-main>
        <!-- 路由占位 -->
        <div class="router">
          <router-view></router-view>
        </div>

      </el-main>
      <hr>
    </el-container>
  </el-container>
</el-container>
</template>

<script>
  export default {
    data() {
      return {
        level:'',
        name:'',
        // 默认不折叠
        isCollapse: false,
      }
    },
    mounted() {
      this.level = sessionStorage.getItem('level')
      this.name = sessionStorage.getItem('userName')
    },
    methods: {
      // goHome(){
      //   this.$router.push('/test/home')
      // },
      //权限管理
      juseAdmin(){
        this.$router.push('/test/level')
      },
      //项目管理
      projectAdmin(){
        this.$router.push('/test/project')
      },
      //员工管理
      goStaff(){
        this.$router.push('/test/staff')
      },
      //PE薪资管理
      payAdmin(){
        if(this.level == 3){
          this.$router.push('/test/payAdminAdd')
        } else {
          this.$router.push('/test/payAdminAudit')
        }
      },
      //个人信息查看
      personInfo(){
        this.$router.push('/test/personInfo')
      },
      //新增报销单
      myReimbursement(){
        this.$router.push('/test/myReimbursement')
      },
      //报销单管理
      reimbursementManage(){
        this.$router.push('/test/reimbursementManage')
      },
      //支付凭证管理
      payment(){
        if (this.level == 1) {
          this.$router.push('/test/addPayment')
        } else{
          this.$router.push('/test/seePayment')
        }
      },
      //薪资发放记录
      payrollRecord(){
        this.$router.push('/test/payrollRecord')
      },
      //测试用
      //新增工资单
      payAdminTest(){
         this.$router.push('/test/payAdminAdd')
      },
      //新增支付凭证
      paymentTest(){
        this.$router.push('/test/addPayment')
      },
      // 路由跳转
      fn (path) {
        this.$router.push(path)
      },
      // 退出登录
      logOut () {
        sessionStorage.removeItem('token')
        sessionStorage.removeItem('level')
        sessionStorage.removeItem('role')
        sessionStorage.removeItem('userName')
        this.$router.push('/login')
      },
      // 菜单的折叠与展开
      togleCollapse(){
        this.isCollapse = !this.isCollapse
      },
      handleSelect(key, keyPath){
        this.cur2 = keyPath
      }
    },
  };
</script>

<style lang="less" scoped>
  .el-container {
    height: 100%;
  }

  .el-header {
    background-color: #373f41;
    display: flex;
    justify-content: space-between;
    padding-left: 0;
    align-items: center;
    color: #fff;
    font-size: 25px;
    > div {
      display: flex;
      align-items: center;
      img {
        margin-left: 15px;
        height: 40px;
      }
      span {
        margin-left: 15px;
      }
    }
    .user{
      color: #fff;
    }
  }

  .el-footer {
    background-color: #fff;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    background-color: #333744;

    .el-menu {
      border: none;
    }
  }

  .el-main{
    background-color: #fff;
    padding: 0;
  }

  .router {
    margin: 24px 28px 0 0;
    padding: 0 20px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .toggle-button {
    background-color: #4A5064;
    font-size: 10px;
    line-height: 24px;
    color: #fff;
    text-align: center;
    letter-spacing: 0.2em;
    // 鼠标放上去变成小手
    cursor: pointer;
  }

  .bread{
    width: 95%;
    height: 20px;
    border: 1px solid #eee;
    background-color: #eee;
    padding-bottom: 30px;
    padding: 20px;
  }

  .title-header{
    font-family: SourceHanSansSC;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    font-style: normal;
    letter-spacing: 0px;
    line-height: 30px;
    text-decoration: none;
    margin-bottom: 10px;
}

</style>
